import threading
import win32gui
from pk.WindowManager import WindowManager


# 选择窗口
class MoveWin:
    def __init__(self, setupui):
        self.setupUi = setupui
        self.threads = []  # 用于存储所有挖图线程
        self.stop_flag = threading.Event()

    def btn_command(self):
        if self.setupUi.selectHwnd:
            for hwnd in self.setupUi.selectHwnd:
                left, top, right, bottom = win32gui.GetWindowRect(hwnd)
                print(left, top)
                thread = threading.Thread(target=WindowManager.set_window_size, args=(hwnd, left, top, 640, 512))
                thread.daemon = True
                thread.start()
        else:
            self.setupUi.add_log("未选择窗口，无法调整界面")
            return
